package com.mingdinggroup.app.util;

import android.util.Base64;

import java.io.File;
import java.io.FileInputStream;

/**
 * 作者：woodnaonly on 2017/3/14 14:11
 * 邮箱：497917264@qq.com
 * 内容：
 * 备注：
 */
public class Base64Utils {

    public static String base64(String audioFilepath) {
        String encodedString = null;
        File file = new File(audioFilepath);
        FileInputStream inputFile = null;
        try {
            inputFile = new FileInputStream(file);
            byte[] buffer = new byte[(int) file.length()];
            inputFile.read(buffer);
            inputFile.close();
            encodedString = Base64.encodeToString(buffer, Base64.DEFAULT);
            return encodedString;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}
